$(document).ajaxSend(function(e, xqr, op) {
    var token = localStorage.getItem("user_token");
    xqr.setRequestHeader("user_token",token);
});


function getUserInfo(url) {
    $.ajax({
        type: "get",
        url: url,
        success: function (result) {
            if(result.code == 200 && result.data != null) {
                var userInfo = result.data;
                $(".left .card h3").text(userInfo.userName);
            }else {
                alert("当前未登入,请先登入");
                location.href = "blog_login.html";
            }
        }
    });
}

function logout() {
    localStorage.removeItem("user_token");
    location.href = "blog_login.html";
}